/*
 * $Id: iBoxStyle.java 110 2009-05-06 11:08:58Z meyer@alphatec.de $
 * 
 *
 * Copyright 2009 DeltaDesk
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *   http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
 * implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package deltadesk.gui.deltagui.widget.box;

import java.awt.BasicStroke;
import java.awt.Color;
import java.awt.Graphics2D;
import java.awt.Paint;
import java.awt.Rectangle;
import java.awt.Shape;
import java.awt.Stroke;
import java.awt.geom.GeneralPath;
import java.awt.geom.RoundRectangle2D;


/**
 * iBoxStyle
 * 
 * Inspired by the panels of DhilshukReddy.
 * 
 * @author Andreas Meyer
 * @version $Revision: 110 $
 */
public class iBoxStyle implements BoxStyle {


	/**
	 * @see deltadesk.gui.deltagui.graphics.Renderable#render(java.awt.Graphics2D)
	 */
	public void render(final Graphics2D g2) {
		
		final Rectangle rect = g2.getClipBounds();
        int width = rect.width;
        int height = rect.height;

		Shape shape = null;
		Paint paint = null;
		Stroke stroke = null;

		paint = new Color(0, 0, 0, 255);
		shape = new RoundRectangle2D.Double(0, 0, width, height, 26, 26);
		g2.setPaint(paint);
		g2.fill(shape);
		paint = new Color(0, 0, 0, 255);
		shape = new RoundRectangle2D.Double(1, 1, width - 2, height - 2, 15.0, 15.0);
		g2.setPaint(paint);
		paint = new Color(136, 136, 136, 136);
		stroke = new BasicStroke(1.0f, 0, 0, 4.0f, null, 0.0f);
		shape = new RoundRectangle2D.Double(1, 1, width - 2, height - 2, 15.0, 15.0);
		g2.setPaint(paint);
		g2.setStroke(stroke);
		g2.draw(shape);
		
		//TODO: Requires JDK 1.6
//		paint = new LinearGradientPaint(new Point2D.Double(321.125,
//				205.1853790283203), new Point2D.Double(321.125, 300.3125),
//				new float[] { 0.0f, 1.0f }, new Color[] {
//						new Color(255, 255, 255, 255), new Color(0, 0, 0, 0) },
//				MultipleGradientPaint.CycleMethod.NO_CYCLE,
//				MultipleGradientPaint.ColorSpaceType.SRGB, new AffineTransform(
//						1.0f, 0.0f, 0.0f, 1.0f, -189.4317169189453f,
//						-220.40145874023438f));
		shape = new GeneralPath();
		((GeneralPath) shape).moveTo(15.1308f, 1.8172914f);
		((GeneralPath) shape).curveTo(9.820799f, 1.8172914f, 2.1307993f, 4.507291f, 2.1307993f, 13.817291f);
		((GeneralPath) shape).lineTo(2.1307993f, 31.78604f);
		((GeneralPath) shape).curveTo(39.09004f, 37.30802f, 86.78241f, 40.69229f, width / 2, 40.69229f);
		((GeneralPath) shape).curveTo(width / 2, 40.69229f, width / 2 + 30, 38.130333f, width - 1, 33.84854f);
		((GeneralPath) shape).lineTo(width - 1, 11.817291f);
		((GeneralPath) shape).curveTo(width - 1, 6.507291f, width - 5, 2.8172914f, width - 13, 1.8172914f);
		((GeneralPath) shape).lineTo(18.1308f, 1.8172914f);
		((GeneralPath) shape).closePath();
		
		g2.setPaint(paint);
		g2.fill(shape);
	}

}
